#include<bits/stdc++.h>
#define int long long
using namespace std;
int b[500005],a[500005];
struct f{
	int l,r,sum;
}tr[500005*4];
int n,k;
void jianshu(int p,int l,int r){
	tr[p].l=l,tr[p].r=r;tr[p].sum=0;
	if(l==r){return;}
	int mid=(tr[p].l+tr[p].r)/2;
	jianshu(p*2,l,mid),jianshu(p*2+1,mid+1,r);
}
void xiu(int p,int l,int k){
	if(tr[p].l==tr[p].r){
		tr[p].sum=max(tr[p].sum,k);return;
	}
	int mid=(tr[p].l+tr[p].r)/2;
	if(l<=mid) xiu(p*2,l,k);
	else xiu(p*2+1,l,k);
	tr[p].sum=max(tr[p*2].sum,tr[p*2+1].sum);
}
int cha(int p,int l,int r){
	if(tr[p].l>=l&&tr[p].r<=r){
		return tr[p].sum;
	}
	int mid=(tr[p].l+tr[p].r)/2,ans=0;
	if(l<=mid) ans=cha(p*2,l,r);
	if(r>mid) ans=max(ans,cha(p*2+1,l,r));
	return ans;
}
int check(int sum){
	for(int i=1;i<=n;i++){
		jianshu(1,1,n);
		xiu(1,a[i],1);
		for(int j=i+1;j<=n;j++){
			int kl=sum-b[a[j]],num=0;
			if(kl<b[1]) num=0;
			else{
				int op=kl;
				kl=lower_bound(b+1,b+1+n,kl)-b;
				if(b[kl]>op) kl--;
				num=cha(1,1,kl)+1;
			}
			if(b[a[i]]+b[a[j]]<=sum&&num>=k) return 1;
			xiu(1,a[j],num);
		}
	}
	return 0;
}
signed main(){
	freopen("sub.in","r",stdin);
	freopen("sub.out","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];b[i]=a[i];
	}
	sort(b+1,b+1+n);
	for(int i=1;i<=n;i++) a[i]=lower_bound(b+1,b+1+n,a[i])-b;
	int l=2,r=2000000000,sum=2000000000;
	while(l<=r){
		int mid=(l+r)/2;
		if(check(mid)) r=mid-1,sum=mid;
		else l=mid+1;
	}
	cout<<sum;
	return 0;
}


